home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / v10n22.arc / TRYITRIG.ASM < prev    next >
Assembly Source File  |  1991-12-08  |  4KB  |  135 lines

  1.         title   TRYITRIG - Demonstration Program for ITRIG Module
  2.         page    55,132
  3.  
  4. ; TRYITOA.ASM --- Simple Interactive Demo of ITRIG Module
  5. ; Copyright (C) 1991 Ray Duncan
  6. ;
  7. ; To build:     MAKE TRYITRIG
  8.  
  9. stdin   equ     0                       ; standard input handle
  10. stdout  equ     1                       ; standard output handle
  11.  
  12. cr      equ     0dh                     ; ASCII carriage return
  13. lf      equ     0ah                     ; ASCII line feed
  14.  
  15. DGROUP  group   _DATA
  16.  
  17. _TEXT   segment word public 'CODE'
  18.  
  19.         assume  cs:_TEXT,ds:_DATA
  20.  
  21.         extrn   lcvt:near
  22.         extrn   atoi:near
  23.         extrn   sine:near
  24.         extrn   cosine:near
  25.  
  26. main    proc    near
  27.  
  28.         mov     ax,_DATA                ; make our data segment
  29.         mov     ds,ax                   ; addressable...
  30.         mov     es,ax
  31.         
  32. main1:  mov     dx,offset prompt        ; display a prompt
  33.         mov     cx,p_len                ; to the user...
  34.         mov     bx,stdout               ; "Enter degrees: " 
  35.         mov     ah,40h
  36.         int     21h
  37.  
  38.         mov     dx,offset inbuff        ; read keyboard entry
  39.         mov     cx,80                   ; from the user...
  40.         mov     bx,stdin
  41.         mov     ah,3fh
  42.         int     21h
  43.         jc      main2                   ; if error, just exit
  44.  
  45.         cmp     ax,2                    ; did he enter anything?
  46.         je      main2                   ; empty line, exit
  47.  
  48.         mov     dx,offset msg1          ; display "The sine is: "
  49.         mov     cx,msg1_len             ; to the user...
  50.         mov     bx,stdout
  51.         mov     ah,40h
  52.         int     21h
  53.         
  54.         mov     si,offset inbuff        ; convert convert user's 
  55.         call    atoi                    ; input to binary in AX
  56.  
  57.         push    ax                      ; save copy of angle    
  58.         call    sine                    ; get sine of angle
  59.                                         
  60.                                         ; convert sine for output
  61.         cwd                             ; DX:AX = sine
  62.         mov     bh,4                    ; decimal places
  63.         mov     bl,10                   ; field width
  64.         mov     cx,0                    ; special formatting
  65.         mov     si,offset outbuff       ; DS:SI = output buffer
  66.         call    lcvt
  67.  
  68.         mov     cx,ax                   ; CX = string length
  69.         mov     dx,si                   ; DS:DX = string address 
  70.         mov     bx,stdout               ; now display converted
  71.         mov     ah,40h                  ; ASCII string...
  72.         int     21h                     ; 
  73.  
  74.         mov     dx,offset msg2          ; display "The cosine is: "
  75.         mov     cx,msg2_len             ; to the user...
  76.         mov     bx,stdout
  77.         mov     ah,40h
  78.         int     21h
  79.         
  80.         pop     ax                      ; get copy of angle     
  81.         call    cosine                  ; get cosine of angle
  82.                                         
  83.                                         ; convert cosine for output
  84.         cwd                             ; DX:AX = cosine
  85.         mov     bh,4                    ; decimal places
  86.         mov     bl,10                   ; field width
  87.         mov     cx,0                    ; special formatting
  88.         mov     si,offset outbuff       ; DS:SI = output buffer
  89.         call    lcvt
  90.  
  91.         mov     cx,ax                   ; CX = string length
  92.         mov     dx,si                   ; DS:DX = string address 
  93.         mov     bx,stdout               ; now display converted
  94.         mov     ah,40h                  ; ASCII string...
  95.         int     21h                     ; 
  96.         jc      main2                   ; if error, just exit
  97.  
  98.         jmp     main1                   ; do it again...
  99.  
  100.  
  101. main2:  mov     ax,4c00h                ; final exit to MS-DOS
  102.         int     21h
  103.  
  104. main    endp
  105.  
  106. _TEXT   ends
  107.  
  108.  
  109. _DATA   segment word public 'DATA'
  110.  
  111. prompt  db      cr,lf,lf,'Enter angle:   '
  112. p_len   equ     $-prompt
  113.  
  114. msg1    db      cr,'The sine is:   '
  115. msg1_len equ    $-msg1
  116.  
  117. msg2    db      cr,lf,'The cosine is: '
  118. msg2_len equ    $-msg2
  119.  
  120. inbuff  db      80 dup (?)
  121.  
  122. outbuff db      10 dup (?)
  123.  
  124. _DATA   ends
  125.  
  126.  
  127. STACK   segment para stack 'STACK'
  128.         
  129.         db      128 dup (?)
  130.  
  131. STACK   ends
  132.  
  133.         end     main
  134.  
  135.